package com.j256.ormlite.logger;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class LocalLog
  implements Log
{
  private static final Log.Level DEFAULT_LEVEL = Log.Level.DEBUG;
  public static final String LOCAL_LOG_FILE_PROPERTY = "com.j256.ormlite.logger.file";
  public static final String LOCAL_LOG_LEVEL_PROPERTY = "com.j256.ormlite.logger.level";
  public static final String LOCAL_LOG_PROPERTIES_FILE = "/ormliteLocalLog.properties";
  private static final List<PatternLevel> classLevels;
  private static final ThreadLocal<DateFormat> dateFormatThreadLocal = new ThreadLocal()
  {
    protected DateFormat initialValue()
    {
      return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss,SSS");
    }
  };
  private static PrintStream printStream;
  private final String className;
  private final Log.Level level;

  static
  {
    classLevels = readLevelResourceFile(LocalLog.class.getResourceAsStream("/ormliteLocalLog.properties"));
    openLogFile(System.getProperty("com.j256.ormlite.logger.file"));
  }

  public LocalLog(String paramString)
  {
    this.className = LoggerFactory.getSimpleClassName(paramString);
    List localList = classLevels;
    Object localObject = null;
    if (localList != null)
    {
      Iterator localIterator = classLevels.iterator();
      while (localIterator.hasNext())
      {
        PatternLevel localPatternLevel = (PatternLevel)localIterator.next();
        if ((localPatternLevel.pattern.matcher(paramString).matches()) && ((localObject == null) || (localPatternLevel.level.ordinal() < ((Log.Level)localObject).ordinal())))
          localObject = localPatternLevel.level;
      }
    }
    String str;
    if (localObject == null)
    {
      str = System.getProperty("com.j256.ormlite.logger.level");
      if (str != null)
        break label123;
      localObject = DEFAULT_LEVEL;
    }
    while (true)
    {
      this.level = ((Log.Level)localObject);
      return;
      try
      {
        label123: Log.Level localLevel = Log.Level.valueOf(str.toUpperCase());
        localObject = localLevel;
      }
      catch (IllegalArgumentException localIllegalArgumentException)
      {
        throw new IllegalArgumentException("Level '" + str + "' was not found", localIllegalArgumentException);
      }
    }
  }

  private static List<PatternLevel> configureClassLevels(InputStream paramInputStream)
    throws IOException
  {
    BufferedReader localBufferedReader = new BufferedReader(new InputStreamReader(paramInputStream));
    ArrayList localArrayList = new ArrayList();
    while (true)
    {
      String str = localBufferedReader.readLine();
      if (str == null)
        return localArrayList;
      if ((str.length() != 0) && (str.charAt(0) != '#'))
      {
        String[] arrayOfString = str.split("=");
        if (arrayOfString.length != 2)
        {
          System.err.println("Line is not in the format of 'pattern = level': " + str);
        }
        else
        {
          Pattern localPattern = Pattern.compile(arrayOfString[0].trim());
          try
          {
            Log.Level localLevel = Log.Level.valueOf(arrayOfString[1].trim());
            localArrayList.add(new PatternLevel(localPattern, localLevel));
          }
          catch (IllegalArgumentException localIllegalArgumentException)
          {
            System.err.println("Level '" + arrayOfString[1] + "' was not found");
          }
        }
      }
    }
  }

  public static void openLogFile(String paramString)
  {
    if (paramString == null)
    {
      printStream = System.out;
      return;
    }
    try
    {
      printStream = new PrintStream(new File(paramString));
      return;
    }
    catch (FileNotFoundException localFileNotFoundException)
    {
      throw new IllegalArgumentException("Log file " + paramString + " was not found", localFileNotFoundException);
    }
  }

  private void printMessage(Log.Level paramLevel, String paramString, Throwable paramThrowable)
  {
    if (!isLevelEnabled(paramLevel));
    do
    {
      return;
      StringBuilder localStringBuilder = new StringBuilder(128);
      localStringBuilder.append(((DateFormat)dateFormatThreadLocal.get()).format(new Date()));
      localStringBuilder.append(" [").append(paramLevel.name()).append("] ");
      localStringBuilder.append(this.className).append(' ');
      localStringBuilder.append(paramString);
      printStream.println(localStringBuilder.toString());
    }
    while (paramThrowable == null);
    paramThrowable.printStackTrace(printStream);
  }

  // ERROR //
  static List<PatternLevel> readLevelResourceFile(InputStream paramInputStream)
  {
    // Byte code:
    //   0: aconst_null
    //   1: astore_1
    //   2: aload_0
    //   3: ifnull +16 -> 19
    //   6: aload_0
    //   7: invokestatic 258	com/j256/ormlite/logger/LocalLog:configureClassLevels	(Ljava/io/InputStream;)Ljava/util/List;
    //   10: astore 6
    //   12: aload 6
    //   14: astore_1
    //   15: aload_0
    //   16: invokevirtual 263	java/io/InputStream:close	()V
    //   19: aload_1
    //   20: areturn
    //   21: astore 4
    //   23: getstatic 178	java/lang/System:err	Ljava/io/PrintStream;
    //   26: new 128	java/lang/StringBuilder
    //   29: dup
    //   30: invokespecial 129	java/lang/StringBuilder:<init>	()V
    //   33: ldc_w 265
    //   36: invokevirtual 135	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   39: aload 4
    //   41: invokevirtual 268	java/lang/StringBuilder:append	(Ljava/lang/Object;)Ljava/lang/StringBuilder;
    //   44: invokevirtual 140	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   47: invokevirtual 185	java/io/PrintStream:println	(Ljava/lang/String;)V
    //   50: aload_0
    //   51: invokevirtual 263	java/io/InputStream:close	()V
    //   54: aconst_null
    //   55: areturn
    //   56: astore 5
    //   58: aconst_null
    //   59: areturn
    //   60: astore_2
    //   61: aload_0
    //   62: invokevirtual 263	java/io/InputStream:close	()V
    //   65: aload_2
    //   66: athrow
    //   67: astore 7
    //   69: aload_1
    //   70: areturn
    //   71: astore_3
    //   72: goto -7 -> 65
    //
    // Exception table:
    //   from	to	target	type
    //   6	12	21	java/io/IOException
    //   50	54	56	java/io/IOException
    //   6	12	60	finally
    //   23	50	60	finally
    //   15	19	67	java/io/IOException
    //   61	65	71	java/io/IOException
  }

  void flush()
  {
    printStream.flush();
  }

  public boolean isLevelEnabled(Log.Level paramLevel)
  {
    return this.level.isEnabled(paramLevel);
  }

  public void log(Log.Level paramLevel, String paramString)
  {
    printMessage(paramLevel, paramString, null);
  }

  public void log(Log.Level paramLevel, String paramString, Throwable paramThrowable)
  {
    printMessage(paramLevel, paramString, paramThrowable);
  }

  private static class PatternLevel
  {
    Log.Level level;
    Pattern pattern;

    public PatternLevel(Pattern paramPattern, Log.Level paramLevel)
    {
      this.pattern = paramPattern;
      this.level = paramLevel;
    }
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.j256.ormlite.logger.LocalLog
 * JD-Core Version:    0.6.2
 */